Skip to content

TEL-886: Media Port rework - #802

Merged
alexlivekit merged 14 commits into
mainfrom
tel-886/media-port
Aug 31, 2026
Merged

TEL-886: Media Port rework#802
alexlivekit merged 14 commits into
mainfrom
tel-886/media-port

Conversation

@alexlivekit

@alexlivekit alexlivekit commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

This change is intended to:

  • Have little functional differences between it an main.
    • the one known thing: Plug-in processor moved back to ingesting 48khz audio and returning 48khz audio.
  • Add interface for clarity.
  • Add machinery to support renegotiation, early media, hold, etc. All these are still disabled for now, but there.
  • Add tests.

@alexlivekit
alexlivekit requested a review from a team as a code owner August 20, 2026 19:20
devin-ai-integration[bot]

This comment was marked as resolved.

@alexlivekit

Copy link
Copy Markdown
Contributor Author

Huh, the race in CI is real, and is apparently a problem in media-sdk (yay zerocopy) that previous tests simply did not expose.
So... no regression compared to main.

@alexfish8

Copy link
Copy Markdown
Contributor

Huh, the race in CI is real, and is apparently a problem in media-sdk (yay zerocopy) that previous tests simply did not expose. So... no regression compared to main.

Will fix this in media-sdk.

devin-ai-integration[bot]

This comment was marked as resolved.

@alexlivekit alexlivekit mentioned this pull request Aug 21, 2026
Comment thread pkg/sip/inbound.go Outdated
Comment thread pkg/sip/inbound.go
Comment thread pkg/sip/inbound.go Outdated
Comment thread pkg/sip/media_pipeline.go Outdated
Comment thread pkg/sip/media_pipeline.go Outdated
Comment thread pkg/sip/media_pipeline.go Outdated
Comment thread pkg/sip/media_port.go
Comment thread pkg/sip/media_port.go
Comment thread pkg/sip/outbound.go
Comment thread pkg/sip/room.go

// WriteOutboundDTMFTo tells the room where to send DTMF to.
// Returns the previously-set writer (if one exists).
WriteOutboundDTMFTo(w msdk.WriteCloser[*livekit.SipDTMF]) msdk.WriteCloser[*livekit.SipDTMF]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason to use pointers in livekit.SipDTMF? It's a tiny payload, might as well just copy it around.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the thread safety is a good benefit of copying. Fair enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WriteSample passes lock by value: github.com/livekit/protocol/livekit.SipDTMF contains google.golang.org/protobuf/runtime/protoimpl.MessageState contains sync.Mutex I guess this is one,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, it's a protobuf. Can we swap it for a non-proto struct? I remember we had races on proto structs before.

Base automatically changed from tel-886/prep to main August 21, 2026 16:42
@alexlivekit
alexlivekit force-pushed the tel-886/media-port branch 3 times, most recently from 47b61bd to 5ad9b22 Compare August 21, 2026 20:59
@alexfish8

Copy link
Copy Markdown
Contributor

Huh, the race in CI is real, and is apparently a problem in media-sdk (yay zerocopy) that previous tests simply did not expose. So... no regression compared to main.

Will fix this in media-sdk.

Fixed in media-sdk#81.

devin-ai-integration[bot]

This comment was marked as resolved.

Comment thread pkg/sip/inbound.go Outdated
Comment thread pkg/sip/inbound.go Outdated
Comment thread pkg/sip/inbound.go Outdated
Comment thread pkg/sip/outbound.go Outdated
Comment thread pkg/sip/outbound.go Outdated
Comment thread pkg/sip/room.go

// WriteOutboundDTMFTo tells the room where to send DTMF to.
// Returns the previously-set writer (if one exists).
WriteOutboundDTMFTo(w msdk.WriteCloser[*livekit.SipDTMF]) msdk.WriteCloser[*livekit.SipDTMF]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, it's a protobuf. Can we swap it for a non-proto struct? I remember we had races on proto structs before.

Comment thread pkg/sip/media_port.go
Comment thread pkg/sip/inbound.go Outdated
Comment thread pkg/sip/inbound.go Outdated
if s.cli != nil { // Process reinvite for existing outbound calls
oc := s.cli.getActiveCall(cc.ID())
newCSeq := cc.InviteCSeq()
if oc != nil && oc.cc != nil && oc.cc.InviteCSeq() < newCSeq {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pre-existing, behavior, but, in a follow-up PR, we should reply with some kind of error if the new sequence number is lower than the existing one (per spec, I think this should be internal server error). Adding a todo.

Comment thread pkg/sip/inbound.go Outdated
Comment thread pkg/sip/outbound.go Outdated
Comment thread pkg/sip/inbound.go Outdated
Comment thread pkg/sip/outbound.go Outdated
devin-ai-integration[bot]

This comment was marked as resolved.

@dennwc

dennwc commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

But lets land #819 first, as it's safer and easier to validate.

@alexlivekit
alexlivekit merged commit 4568727 into main Aug 31, 2026
7 checks passed
@alexlivekit
alexlivekit deleted the tel-886/media-port branch August 31, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants